using UnityEngine;

namespace ZFramework.Runtime
{
    public class ItemInstanceObject : ObjectBase
    {
        private IResourceMgr _resourceMgr;
        //private Object _itemAsset;

        public override void Release()
        {
            Object.Destroy((Object)Instance);
            _resourceMgr.UnloadAsset(Name);
        }

        public static ItemInstanceObject Create(string name, Object entityAsset, Object entityInstance, IResourceMgr resourceMgr)
        {
            var itemInstanceObject = ReferencePool.Acquire<ItemInstanceObject>();
            itemInstanceObject.Initialize(name, entityInstance);
            //itemInstanceObject._itemAsset = entityAsset;
            itemInstanceObject._resourceMgr = resourceMgr;
            return itemInstanceObject;
        }

        public override void Clear()
        {
            base.Clear();
            //_itemAsset = null;
        }
    }
}
